<?php
include('conexion.php');
$serv = conectar();
session_start();
if (($_POST['Nombre'] == "") || ($_POST['Password'] =="")) {
	$_SESSION['error'] = "Debe de rellenar todos los campos";
	header("Location:index.php");
}else{
	$peticion = mysql_query('SELECT * FROM profesor WHERE login="'.$_POST["Nombre"].'" AND psw="'.$_POST["Password"].'";');
	
	if ($row = mysql_fetch_array($peticion))  {
		$_SESSION['auth'] = "yes";
		$_SESSION['admin'] = "no";
		$_SESSION['error'] = "";
		$_SESSION['Nombre'] = $row['nombre'];
		$_SESSION['tutor'] = "no";
		$_SESSION['jefe_estudios'] = "no";
		$_SESSION['id'] = $row['id_profesor'];
		
		if($row['tutor'] != ""){
			$_SESSION['tutor'] = "yes";
		}

		if($row['jefe_estudios'] == "1"){
			$_SESSION['jefe_estudios'] = "yes";
		}
		header("location:index.php");
		
	}else{
		$_SESSION['auth'] = "";
		$_SESSION['error'] = "Error de login";
		header("location:index.php");
	}
}
//header('Location: index.php');
?>
